<template>
  <div class="toast" v-show="visible">
    <div>
      <img src="@/assets/img/cart/tick.svg" alt="">
      <br>
      <p>{{ message }}</p>
    </div>
  </div>
</template>


<script>

export default {
  name: 'Toast',
  data() {
    return {
      message: '',
      visible: false
    }
  },
  methods: {
    // 设置默认值 操作
    show(msg = '功能还未开发哦~', duration = 1000) {
      this.message = msg
      this.visible = true
      setTimeout(() => {
        this.visible = false
        this.message = ''
      }, duration)
    }
  }

}

</script>


<style scoped>
.toast {
  width: 220px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, .5);
  color: white;
  padding: 8px 10px;
  border-radius: 10px;
  z-index: 999;
}

p {
  text-align: center;
}

img {
  position: absolute;
  bottom: 60%;
  right: 45%;
  padding-bottom: 3px;
}
</style>